package cn.edu.xjtu.work.trailingZeroes;

/**
 * 172. 阶乘后的零
 * 
 * 给定一个整数 n，返回 n! 结果尾数中零的数量。
 */
public class Soluition {
  public static void main(String[] args) {
    System.out.println(trailingZeroes(13));
  }

  public static int trailingZeroes(int n) {
    double factor = fac(n);
    System.out.println(factor);
    int ret = 0;
    while (factor % 10 == 0) {
      ret++;
      factor /= 10;
    }
    return ret;
  }

  public static double fac(int n) {
    if (n == 0 || n == 1) {
      return 1;
    }
    return fac(n - 1) * n;
  }
}
